<?php

namespace App\Jobs;

use App\Entity\UserEntity;
use App\Services\Distribution\Poster;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class DistributionPosterJob implements ShouldQueue
{
    use Dispatchable; use InteractsWithQueue; use Queueable; use SerializesModels;

    /**
     * @var UserEntity
     */
    public $user;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(UserEntity $user)
    {
        $this->user = $user;
    }

    /**
     * @throws \Exception
     */
    public function handle()
    {
        $poster = new Poster($this->user);
        $poster->make();
    }
}
